Skip to content

feat: add text-to-speech announcement hooks#2

Merged
timoconnellaus merged 2 commits intomasterfrom
feature/extensions
Jul 8, 2025
Merged

feat: add text-to-speech announcement hooks#2
timoconnellaus merged 2 commits intomasterfrom
feature/extensions

Conversation

@timoconnellaus
Copy link
Owner

Summary

  • Add TTS announcement hooks for all Claude Code event types
  • Enable audio notifications for task completion, tool usage, and notifications
  • Cross-platform support for macOS, Linux, and Windows

Features

This PR adds the following text-to-speech announcement hooks:

  • announceStop - Announces when main tasks complete
  • announceSubagentStop - Announces when subagent tasks complete
  • announcePreToolUse - Announces before tool execution
  • announcePostToolUse - Announces after tool execution
  • announceNotification - Speaks notification messages aloud

Key Features:

  • 🔊 Cross-platform TTS support (macOS say, Linux espeak, Windows PowerShell SAPI)
  • 🎯 Customizable messages with template variables ({toolName}, {sessionId}, {timestamp}, {message})
  • 🎤 Voice selection and speech rate configuration
  • 🛠️ Custom TTS command support for other systems
  • 🎛️ Tool matchers for selective announcements (e.g., only announce Bash commands)
  • 🔄 Backward compatibility with legacy announceTaskCompletion names

Example Usage

import { defineHooks, announceStop, announcePreToolUse } from '@timoaus/define-claude-code-hooks';

export default defineHooks({
  // Announce when tasks complete
  Stop: [announceStop({ 
    message: "Task completed for session {sessionId}",
    voice: "Samantha"
  })],
  
  // Announce before running Bash commands
  PreToolUse: [announcePreToolUse('Bash', {
    message: "Running {toolName} command"
  })]
});

Test Plan

  • Tested all hooks on macOS with various configurations
  • Verified template variable replacement
  • Confirmed async execution doesn't block Claude Code
  • TypeScript compilation passes

🤖 Generated with Claude Code

timoconnellaus and others added 2 commits July 8, 2025 13:56
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add announcement hooks for all Claude Code event types:
- announceStop: announces task completion
- announceSubagentStop: announces subagent task completion
- announcePreToolUse: announces before tool execution
- announcePostToolUse: announces after tool execution
- announceNotification: speaks notification messages

Features:
- Cross-platform TTS support (macOS, Linux, Windows)
- Customizable messages with template variables
- Voice and speech rate configuration
- Custom TTS command support
- Tool matchers for selective announcements

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@timoconnellaus timoconnellaus merged commit b9dcc29 into master Jul 8, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant